/*
 * @Description: 
 * @Author: chaixinyu
 * @Date: 2022-12-20 19:08:34
 * @LastEditors: 47
 * @LastEditTime: 2023-04-16 15:26:56
 */
import { fileURLToPath, URL } from 'node:url'

const fs = require('fs')
const path = require('path')

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        vueJsx(),
        Components({
            resolvers: [VantResolver()],
        }),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src',
                import.meta.url))
        }
    },
    // server: {
    //     open: true,
    //     https: {
    //         // 主要是下面两行的配置文件，不要忘记引入 fs 和 path 两个对象
    //         cert: fs.readFileSync(path.join(__dirname, 'src/ssl/cert.crt')),
    //         key: fs.readFileSync(path.join(__dirname, 'src/ssl/cert.key'))
    //     }
    // }
    server: {
        open: true, // 启动项目浏览器自动弹出
        port: 8089, // 启动端口
        proxy: {
            "/team": {
              target: "http://127.0.0.1:3010",
              changeOrigin: true,
              rewrite:path => path.replace(/^\/team/,'')
            }
        }
    }
})